<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>发布评论</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .comment-box {
            width: 500px;
            margin: 20px auto;
        }
        h1{
            font-size: 18px;
            margin-bottom: 5px;
        }
        .pub-comment {
            text-align: right;
        }
        .pub-comment textarea {
            display: block;
            width: 100%;
            height: 50px;
            padding: 5px;
        }
        .btns {
            display: flex;
            justify-content: flex-end;
            align-items: center;
            margin-top: 10px;
        }
        .content-count {
            margin-right: 5px;
        }
        .content-count span {
            color: red;
        }
        .pub-comment button {
            background: #0086ff;
            border: none;
            color: #fff;
            padding: 5px 10px;
        }
        .pub-comment button:hover{
            background-color: #4caafc;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="comment-box">
        <h1>评论</h1>
        <div class="pub-comment">
            <textarea class="content"></textarea>
            <div class="btns">
                <div class="content-count">
                    <span>0</span>/200
                </div>
                <button class="pub-btn">发布评论</button>
            </div>
        </div>
    </div>
    <script>
        // 功能一：统计用户输入发布评论内容数字显示在评论框下方，并控制字数不能超过200字。
        let content = document.querySelector(".pub-comment .content")
        let count = document.querySelector(".content-count span")
        let pubBtn = document.querySelector(".pub-btn")
        content.addEventListener("input", function(){
            let length = content.value.length
            if(length >= 200){
                content.value = content.value.slice(0, 200)
            }
            count.innerHTML = content.value.length
        })

    </script>
</body>
</html>